Locale Name to Code Page for Rust
This is a library that converts strings representing locale names to code pages that are used in Windows.
e.g.
- In
en-US
locale, Windows-1252 (code page id:1252
) is used as the ANSI code page, and CP437 (code page id:437
) is used as the OEM code page. - In
ja-JP
locale, Shift_JIS (code page id:932
) is used as both of the ANSI and OEM code pages.
Usage
First, add locale_name_code_page = "<2"
to your Cargo.toml
.
[]
# *snip*
= "<2"
# *snip*
Then, convert strings representing locales to code pages like:
use get_codepage;
use CodePage;
// IConverter has already been defined by you
// *snip*
Obtained codepage (instance of locale_name_code_page::cp_table_type::CodePage
) can be used as follows:
use get_codepage;
Source of Information
FAQ
How can I convert codepage to encoder/decoder?
Use the following libraries:
ANSI encodings (including CJKV languages)
Combine with codepage and encoding_rs.
OEM encodings (except for CJKV languages)
Use oem_cp.
How can I get the current locale?
Use locale_config.
I want to port this library to other languages.
You can use assets/nls_info.json
in your automatic code generation script.
LICENSE
MIT